package com.orangeandbronze.demos.mapreduce;

import com.google.appengine.tools.mapreduce.KeyValue;
import com.google.appengine.tools.mapreduce.Mapper;

@SuppressWarnings("serial")
public class WordCountMapper extends Mapper<KeyValue<String, byte[]>, String, String[]> {

	@Override
	public void map(KeyValue<String, byte[]> data) {
		final String line = new String(data.getValue());
		final String[] words = line.split("\\W+");
		for (String word : words) {
			if (!word.isEmpty()) {
				getContext().emit(word.toLowerCase(), new String[] { "" });
			}
		}
	}
	
}
